package com.cskaoyan.service;

import com.cskaoyan.mapper.MarketCollectMapper;
import com.cskaoyan.model.MarketCollect;
import com.cskaoyan.model.MarketCollectExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description
 * @Author zoe ling
 * @Date 2024/6/11
 */
@Service
public class CollectionServiceImpl implements CollectionService {
    @Autowired
    MarketCollectMapper collectMapper;


    @Override
    public Integer hasCollection(Integer valueId, byte type, int userId) {
        MarketCollectExample example = new MarketCollectExample();
        example.createCriteria().andTypeEqualTo(type)
                .andUserIdEqualTo(userId)
                .andValueIdEqualTo(valueId)
                .andDeletedEqualTo(false);
        List<MarketCollect> marketCollects = collectMapper.selectByExample(example);
        return marketCollects!=null &&marketCollects.size()==1?1:0;
    }
}
